Carbon


ControlActionProcPtr

Header: Controls.h Carbon status: Supported

Defines actions to be performed repeatedly in response to a mouse-down event in a control part.

typedef void(* ControlActionProcPtr) (
    ControlRef theControl, 
    ControlPartCode partCode
);

You would declare your function like this if you were to name it MyControlActionCallback:

void MyControlActionCallback (
    ControlRef theControl, 
    ControlPartCode partCode
);
theControl

A handle to the control in which the mouse-down event occurred.

partCode

A control part code; see “Meta Control Part Code Constants”, “Control Part Code Constants”, and “Control State Part Code Constants”. When the cursor is still in the control part where the mouse-down event first occurred, this parameter contains that control’s part code. When the user drags the cursor outside the original control part, this parameter contains 0.

DISCUSSION

The Control Manager defines the data type ControlActionUPP to identify the universal procedure pointer for this application-defined function:

typedef UniversalProcPtr ControlActionUPP;

You typically use the NewControlActionProc macro like this:

ControlActionUPP myActionUPP;

myActionUPP = NewControlActionProc(MyControlActionCallback);

You typically use the CallControlActionProc macro like this:

CallControlActionProc(MyActionUPP, theControl, partCode);

When a mouse-down event occurs in a control, HandleControlClick and TrackControl respond as is appropriate, typically by highlighting the control or dragging the indicator as long as the user holds down the mouse button. You can define other actions to be performed repeatedly during this interval. To do so, define your own action function and point to it in the actionProc parameter of the TrackControl function or the inAction parameter of HandleControlClick. This is the only way to specify actions in response to all mouse-down events in a control or indicator.

When your action function is called for a control part, the action function is passed a handle to the control and the control’s part code. The action function should then respond as is appropriate. MyActionProc is an example of such an action function. The only exception to this is for indicators that don’t support live feedback.

If the mouse-down event occurs in an indicator of a control that does not support live feedback, your action function should take no parameters, because the user may move the cursor outside the indicator while dragging it.

As an alternative to passing a pointer to your action function in a parameter to TrackControl, you can use the function SetControlAction to store a pointer to the action function in the contrlAction field in the control structure. When you pass Pointer(–1) instead of a function pointer to TrackControl, TrackControl uses the action function pointed to in the control structure.

AVAILABILITY

Supported in Carbon.


© 2000 Apple Computer, Inc. — (Last Updated 5/8/2000)